﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../../lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="../../lib/ligerUI/js/core/base.js" type="text/javascript"></script>
    <script src="../../lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../../lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
    <script src="../../lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="../../lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
    <script src="../../lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
    <script src="../../lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
    <script src="../../lib/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>
    <script src="../../lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
    <script src="../../lib/json2.js" type="text/javascript"></script>
    <script type="text/javascript">
        var manager = null;
        $(function ()
        {
            var sexData = [[1, '男'], [2, '女']];
            $("#maingrid").ligerGrid({
                columns: [
                { display: '主键', name: 'ID', width: 50, type: 'int' },
                { display: '名字', name: 'RealName',
                    editor: { type: 'text' }
                },
                { display: '性别', name: 'Sex', width: 50, type: 'int',
                    render: function (item)
                    {
                        if (parseInt(item.Sex) == 1) return '男';
                        return '女';
                    }
                },
                { display: '年龄', name: 'Age', width: 50, type: 'int' },
                { display: '入职日期', name: 'IncomeDay', type: 'date', width: 100 },
                { display: '地址', name: 'Address',
                    editor: { type: 'text' }, align: 'left', width: 200
                },
                { display: '部门', name: 'DepartmentName', width: 120 }
                ],
                usePager: false, isScroll: false,
                url: "../../service/EmpDataHandler.ashx?Action=get&View=Employee"
            });
            manager = $("#maingrid").ligerGetGridManager();
        });
        function f_add()
        {
            f_openWindow('../../service/EmployeeEdit.aspx?ID=0', '添加员工', 500, 320);  
        }
        function f_modify()
        {
            var row = manager.getSelectedRow();
            if (!row) { alert('请选择行'); return; }
            f_openWindow('../../service/EmployeeEdit.aspx?ID=' + row.ID, '修改员工', 500, 320);
        }
        function f_reload()
        {
            manager.loadData();
        }
        function f_delete()
        {
            var row = manager.getSelectedRow();
            if (!row) { alert('请选择行'); return; }
            $.ligerDialog.waitting("删除中...");
            $.post('../../service/EmpDataHandler.ashx', { ID: row.ID, Action: 'delete' }, function ()
            {
                $.ligerDialog.closeWaitting();
                $.ligerDialog.success( '删除成功!', function ()
                {
                    manager.loadData();
                }); 
            });
        }
        function f_openWindow(url, title, width, height)
        {
            return $.ligerDialog.open({ width: width, height: height, title: title, url: url, buttons: [
            { text: '关闭', onclick: function ()
            {
                $.ligerDialog.close();
            } 
            }
            ], isResize: true
            });
        }
        var alert = function (content)
        {
            $.ligerDialog.alert(content);
        };
       
    </script>
</head>
<body  style="padding:10px">
<a class="l-button" style="width:60px; float:left; margin-left:10px;" onclick="f_add()">添加</a>

<a class="l-button" style="width:60px; float:left; margin-left:10px;" onclick="f_modify()">修改</a>

<a class="l-button" style="width:60px; float:left; margin-left:10px;" onclick="f_delete()">删除</a>

<a class="l-button" style="width:60px; float:left; margin-left:10px;" onclick="f_reload()">刷新</a>
 <div class="l-clear"></div>
    <div id="maingrid" style="margin-top:20px"></div> <br />
       <br /> 
  <div style="display:none;">
   <!-- g data total ttt -->
</div>
</body>
</html>
